package jsyf.oa.dao.system;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import jsyf.oa.entity.system.MessageReceiverEntity;
import jsyf.oa.idao.BaseDao;
import jsyf.oa.ientity.IBaseEntity;
import org.springframework.stereotype.Repository;

/**
 * Created by Maqiuqiu on 2018/7/21.
 */
@Repository
public class MessageReceiverDao extends BaseDao {

    public MessageReceiverDao() {
        this.iBaseEntity = new MessageReceiverEntity();
    }

    @Override
    public IBaseEntity convertJson2Entity(JSONObject json) {
        return JSON.toJavaObject(json, MessageReceiverEntity.class);
    }

    //标记以前的审核人消息为已读
    public void updateReadFlag(String tableName, String condition) {
        StringBuffer sql = new StringBuffer();
        sql.append("update\n");
        sql.append(tableName + "\n");
        sql.append("set read_flag=1\n");
        sql.append("where 1=1\n");
        sql.append(condition);
        super.getJdbcTemplate().update(sql.toString());
    }

}
